package everydayGrade.t4;

/**
 * @Author: Siantar
 * @Date: 2023-12-02-21:02
 * @Description: 1.0
 */
public class T1094 {
    public boolean carPooling(int[][] trips, int capacity) {
        int[] dp = new int[1001];
        for (int[] trip : trips) {
            int value = trip[0], from = trip[1], to = trip[2];
            dp[from] += value;
            dp[to] -= value;
        }
        int num = 0;
        for (int i = 0; i < 1001; i++) {
            num += dp[i];
            if (num > capacity) return false;
        }
        return true;
    }

}
